@layout("/common/_container.html"){
<style>.templateText{flex:1;text-align:right}.templateFrame{flex:5;margin-left:15px;}.btnBox{background:#f1f1f1;position:fixed;bottom:0;width:100%;padding:5px 0;text-align:center;}.btnBox>button{margin:0;color:white;background:#6090b8;padding: 5px 14px;}.btnBox>button:last-of-type{background:white;color:inherit;border:1px solid #999999}input,textarea{padding-left:5px;height: 30px;}</style>
<div style="display: none"><input type="hidden" id="idValue" value=""></div>
<div style="height: 100%;">
    <div style="background: #6090b8;color: white;padding: 5px 10px;">模板保存</div>
    <div style="height: calc(100% - 78px);overflow: auto;padding: 10px 0;">
        <div style="display:flex;align-items: center">
            <div class="templateText">模板类别：<span style="color: red">*</span></div>
            <div class="templateFrame"><span id="templateCategory" style="vertical-align: middle;" onclick="choiceTemplate()"></span><button style="border: 1px solid #999999;background: white;padding: 4px 14px;" type="button" class="btn" onclick="choiceTemplate()" id="Choice">点击选择</button></div>
        </div>
        <div style="display:flex;margin:14px 0;">
            <div class="templateText">模板名称：<span style="color: red">*</span></div>
            <div class="templateFrame"><input type="text" name="caseName" id="caseName"></div>
        </div>
        <div style="display:flex;margin:14px 0;">
            <div class="templateText">主诉：</div>
            <div class="templateFrame"><input type="text"  name="zhushu" id="zhushu"  style="width: 90%;"></div>
        </div>
        <div style="display:flex;margin:14px 0;">
            <div class="templateText">现病史：</div>
            <div class="templateFrame"><input type="text" name="nowMedicalHistory" id="nowMedicalHistory"  style="width: 90%;"></div>
        </div>
        <div style="display:flex;margin:14px 0;">
            <div class="templateText">既往史：</div>
            <div class="templateFrame"><input type="text" name="beforeMedicalHistory" id="beforeMedicalHistory"  style="width: 90%;"></div>
        </div>
        <div style="display:flex;margin:14px 0;">
            <div class="templateText">口腔检查：</div>
            <div class="templateFrame"><textarea name="mouthCheck"  id="mouthCheck"  style="width: 90%;height: 50px;"></textarea></div>
        </div>
        <div style="display:flex;margin:14px 0;">
            <div class="templateText">辅助检查：</div>
            <div class="templateFrame"><textarea name="auxiliaryCheck"  id="auxiliaryCheck"  style="width: 90%;height: 50px;"></textarea></div>
        </div>
        <div style="display:flex;margin:14px 0;">
            <div class="templateText">诊断：</div>
            <div class="templateFrame"><textarea name="diagnose"  id="diagnose"  style="width: 90%;height: 50px;"></textarea></div>
        </div>
        <div style="display:flex;margin:14px 0;">
            <div class="templateText">治疗方案：</div>
            <div class="templateFrame"><textarea name="remedyPlan"  id="remedyPlan"  style="width: 90%;height: 50px;"></textarea></div>
        </div>
        <div style="display:flex;margin:14px 0;">
            <div class="templateText">处置：</div>
            <div class="templateFrame"><textarea name="dispose"  id="dispose"  style="width: 90%;height: 50px;"></textarea></div>
        </div>
        <div style="display:flex;margin:14px 0;">
            <div class="templateText">医嘱：</div>
            <div class="templateFrame"><input type="text" name="doctorAdvice"  id="doctorAdvice"  style="width: 90%;"></div>
        </div>
    </div>
    <div class="btnBox">
        <button type="button" class="btn" onclick="save()">保存</button>
        <button type="button" class="btn" onclick="parent.layer.close(parent.layer.getFrameIndex(window.name))">取消</button>
    </div>
</div>
<script>
    $(function () {
        var remarks1 = window.parent.document.getElementsByClassName("remarks1");
        var remarks2 = window.parent.document.getElementsByClassName("remarks2");
        var remarks3 = window.parent.document.getElementsByClassName("remarks3");
        var remarks4 = window.parent.document.getElementsByClassName("remarks4");
        var remarks5 = window.parent.document.getElementsByClassName("remarks5");
        var a = "",b = "",c = "",d = "",e = "";
        for(var i=0 ; i<remarks1.length ; i++){
            if(remarks1[i].value != ""){
                a += remarks1[i].value + "。"
            }
        }
        for(var u=0 ; u<remarks2.length ; u++){
            if(remarks2[u].value != ""){
                b += remarks2[u].value + "。"
            }
        }
        for(var w=0 ; w<remarks3.length ; w++){
            if(remarks3[w].value != ""){
                c += remarks3[w].value + "。"
            }
        }
        for(var t=0 ; t<remarks4.length ; t++){
            if(remarks4[t].value != ""){
                d += remarks4[t].value + "。"
            }
        }
        for(var l=0 ; l<remarks5.length ; l++){
            if(remarks5[l].value != ""){
                e += remarks5[l].value + "。"
            }
        }
        $("#zhushu").val(window.parent.document.getElementById("zhushu").value);  //主述
        $("#nowMedicalHistory").val(window.parent.document.getElementById("nowMedicalHistory").value);  //现病史
        $("#beforeMedicalHistory").val(window.parent.document.getElementById("beforeMedicalHistory").value);  //既往史
        $("#doctorAdvice").val(window.parent.document.getElementById("doctorAdvice").value);  //医嘱
        $("#mouthCheck").val(a);        //口腔检查
        $("#auxiliaryCheck").val(b);    //辅助检查
        $("#diagnose").val(c);          //辅助检查
        $("#remedyPlan").val(d);        //治疗计划
        $("#dispose").val(e);           //处置
    });
    choiceTemplate = function () {
        var index = layer.open({
            type: 2,
            title: '选择模板类别',
            area: ['60%', '70%'], //宽高
            fix: true, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/doctorLooked/doctor_choiceTemplate'
        });
        this.layerIndex = index;
    };
    function save(){
        var oblogid = $("#idValue").val();
        var caseName = $("#caseName").val();  //模板名称
        var zhushu = $("#zhushu").val();  //主诉
        var nowMedicalHistory = $("#nowMedicalHistory").val();  //现病史
        var beforeMedicalHistory = $("#beforeMedicalHistory").val();  //既往史
        var mouthCheck = $("#mouthCheck").val();  //口腔检查
        var auxiliaryCheck = $("#auxiliaryCheck").val();  //辅助检查
        var diagnose = $("#diagnose").val();  //辅助检查
        var remedyPlan = $("#remedyPlan").val();  //治疗计划
        var dispose = $("#dispose").val();  //处置
        var doctorAdvice = $("#doctorAdvice").val();  //医嘱
        var templateCategory = $("#templateCategory").html();
        if(templateCategory == "" || templateCategory == null){
            alert("请选择模板所属类别");
            return
        }
        if(caseName==null||caseName==""){
            alert("请填写模板名称")
            return
        }
        $.ajax({
            url: Feng.ctxPath + "/doctorLooked/addCaseContent",
            type: "post",
            data: {
                "caseName": caseName,
                "zhushu": zhushu,
                "nowMedicalHistory": nowMedicalHistory,
                "beforeMedicalHistory": beforeMedicalHistory,
                "mouthCheck": mouthCheck,
                "auxiliaryCheck": auxiliaryCheck,
                "diagnose":diagnose,
                "remedyPlan": remedyPlan,
                "dispose": dispose,
                "doctorAdvice": doctorAdvice,
                "oblogid":oblogid
            },
            success: function (data) {
                Feng.success('添加成功!');
                parent.layer.close(parent.layer.getFrameIndex(window.name))
            },
            error: function (data) {
                alert('没有权限，请联系管理员!');
            }
        });
    }
</script>
@}